﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace HXH.Serialization.Abstractions
{
    /// <summary>
    /// 序列化消息器
    /// </summary>
    public interface IMessageSerializer
    {
        /// <summary>
        /// 序列化消息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="message"></param>
        /// <returns></returns>
        byte[] SerializerBytes<T>(T message);
        /// <summary>
        /// 异步序列化消息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="message"></param>
        /// <returns></returns>
        Task<byte[]> SerializerBytesAsync<T>(T message);
        /// <summary>
        /// 反序列化
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="bytes"></param>
        /// <returns></returns>
        T Deserialize<T>(byte[] bytes);
        /// <summary>
        /// 异步反序列化
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="bytes"></param>
        /// <returns></returns>
        Task<T> DeserializeAsync<T>(byte[] bytes);
    }
}
